package design.simdi.code.final_paper.site.panels.administrare.profesori;

import org.apache.wicket.Page;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.basic.MultiLineLabel;
import org.apache.wicket.markup.html.link.ExternalLink;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;

import design.simdi.code.final_paper.core.entities.Person;
import design.simdi.code.final_paper.site.panels.OneButtonPanel;

/**
 * 
 * @author Marius Dumitriu - (Jun 23, 2010 - 12:55:34 AM)
 * 
 */
public class ViewProfesorDetails extends OneButtonPanel {

	private static final long serialVersionUID = 1L;
	private Person professor;

	public ViewProfesorDetails(String id, IModel<Person> model) {
		super(id, model);

	}

	@Override
	public void panelInit() {
		super.panelInit();
		setOutputMarkupId(true);
		professor = (Person) getDefaultModelObject();

		getForm().add(new MultiLineLabel("about", new PropertyModel<String>(professor.getProfesor(), "about")));
		getForm().add(
				new Label("titluUniversitar", new PropertyModel<String>(professor.getProfesor(), "titluUniversitar")));
		getForm().add(
				new ExternalLink("homePage", professor.getProfesor().getHomePage(), professor.getProfesor()
						.getHomePage()));
		getForm().add(new Label("office", new PropertyModel<String>(professor.getProfesor(), "office")));
		getForm().add(new Label("departament", new PropertyModel<String>(professor.getProfesor(), "departament")));
		getForm().add(new Label("fullName", new Model<String>(professor.toString())));
		getForm().add(new Label("email", new PropertyModel<String>(professor.getUser(), "email")));
	}

	@Override
	public void onCANCELButtonSubmit(AjaxRequestTarget target) {
		ProfesoriTabPanel panel = new ProfesoriTabPanel("panel");
		panel.setOutputMarkupId(true);

		Page page = this.getPage();

		page.get("content:tabs:panel").replaceWith(panel);

		target.addComponent(page);

	}

}
